<template>
  <div class="contr">
    <!-- 数据大屏展示内容区域 -->
    <div class="screen" ref="screen">
      <!-- 数据大屏顶部 -->
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist v-if="useStore.AmapTrue" class="tourist" />
          <Sex v-if="useStore.AmapTrue" class="sex" />
          <Age v-if="useStore.AmapTrue" class="age" />
        </div>

        <div class="center">
          <Map class="map" />
          <Line v-if="useStore.AmapTrue" class="line" />
        </div>
        <div class="right">
          <Rank v-if="useStore.AmapTrue" class="rank" />
          <Year v-if="useStore.AmapTrue" class="year" />
          <Counter v-if="useStore.AmapTrue" class="count" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useUserStore } from "@/store/modules/user";
let useStore = useUserStore();
//引入顶部的子组件
import Top from "./components/top/index.vue";
//引入左侧三个子组件
import Tourist from "./components/tourist/index.vue";
import Sex from "./components/sex/index.vue";
import Age from "./components/age/index.vue";

//引入中间两个子组件
import Map from "./components/map/index.vue";
import Line from "./components/line/index.vue";

//引入右侧三个子组件
import Rank from "./components/rank/index.vue";
import Year from "./components/year/index.vue";
import Counter from "./components/counter/index.vue";

//获取数据大屏展示内容盒子的DOM元素
let screen = ref();

onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
});
// function handleOpen(key, keyPath) {
//   const number = ++numa.value;
//   console.log("Menu Opened:", key, keyPath, number);
// }
// function handleClose(key, keyPath) {
//   console.log("Menu Closed:", key, keyPath);
// }
//定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
}
//监听视口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
};
</script>

<style scoped lang="scss">
.contr {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;

  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform-origin: left top;

    .top {
      width: 100%;
      height: 40px;
    }

    .bottom {
      display: flex;

      .right {
        flex: 1;
        margin: 8px;

        display: flex;
        flex-direction: column;

        .rank {
          flex: 1;
        }

        .year {
          flex: 1;
        }

        .count {
          flex: 1;
        }
      }

      .left {
        flex: 1;
        margin: 8px;
        margin-right: 8px;
        display: flex;
        flex-direction: column;

        .tourist {
          flex: 1;
        }

        .sex {
          flex: 1;
        }

        .age {
          flex: 1;
        }
      }

      .center {
        flex: 1.5;
        display: flex;
        flex-direction: column;
        .map {
          margin-right: -3px;
          flex: 3; /* 200px 为初始大小，4 为增长因子，1 为收缩因子 */
          //background-color: #fff;
        }

        .line {
          flex: 1;
        }
      }
    }
  }
}
</style>
